
 begintownscript;

 variables;

 int i,j,k,r1,choice;

 body;

 beginstate INIT_STATE;

	if (get_flag(16,2) == 0) {
		force_instant_terrain_redraw();
		message_dialog("This ancient fort is the source of all the demons, at least you  hope it is. Its walls are thick and high, and they do not look all that old. You think it could easily hold on against an Empire siege for a couple of days at least.","This fortress, though today in a strategically terrible location, must have been of great importance to the people of Faerengrove, prior the Empire rule.");
		set_flag(16,2,1);
}

	if (get_flag(16,0) == 5)
		set_terrain(34,35,0);

	if (get_flag(17,17) != 0 && get_flag(16,8) == 0) {
		force_instant_terrain_redraw();
		message_dialog("You emerge from the chasm and come back to the old fortress. You've stopped the demon lord who was responsible for all the troubles in Faerengrove. The iron should now be returning to the Empire heartlands.","Now all that's left for you to do is to report back to your employer.");
		set_flag(16,8,1);
} 
break;

 beginstate START_STATE;
	if ((get_flag(16,0) <= 3) && (get_flag(16,0) != 0))
		inc_flag(16,0,1);


	if ((get_flag(16,0) == 4) && (has_special_item(0) || has_special_item(10))) {
		message_dialog("The symbols are charging up a lethal beam of energy. just when you think your end has come, you notice that the demon amulet you have is also glowing. It shoots out an energy field surrounding the symbols.","The symbols fire up a beam, but the energy field rebounds the beam back, blowing up the symbols.");
		set_flag(16,0,5);
		set_terrain(34,35,0);
		set_terrain(33,35,0);
		put_boom_on_space(33,32,1,0);
		put_boom_on_space(33,35,1,0);
		put_boom_on_space(31,32,1,0);
		put_boom_on_space(31,35,1,0);
		damage_char(1000,120,1);
		set_terrain(31,32,0);
		set_terrain(31,35,0);
		set_terrain(33,36,0);
		run_animation_sound(152);
force_instant_terrain_redraw();
}

	if ((get_flag(16,0) == 4) && (has_special_item(0) == 0)) {
		message_dialog("The hangings charged up a magical blast of fire. The beams are lethal and your magic isn't strong enough to block the beams. Your death is quite painful.","");
		kill_char(1000,2,0);
		set_flag(16,0,5);
}



break;
		
 beginstate EXIT_STATE;

break;

 beginstate 10;
	if (get_flag(16,0) == 0) {
		set_terrain(33,29,40);
		set_terrain(31,36,38);
force_instant_terrain_redraw();
		play_sound(-5);
		pause(2);
		set_terrain(32,29,40);
		set_terrain(32,36,38);
force_instant_terrain_redraw();
		play_sound(-5);
		pause(2);
		set_terrain(31,29,40);
		set_terrain(33,36,38);
force_instant_terrain_redraw();
		play_sound(-5);
		pause(5);
		message_dialog("You're trapped! You desperately try to search for a button or a switch to save you, you find none. The walls around are also solid, no secret passage will get you out of this one.","Just when you think you'll starve to death, you notice that the symbols on the wall start to glow.");
		set_flag(16,0,1);
		
}
break;

 beginstate 11;
	if (get_flag(16,7) == 0)
		message_dialog("A gush of warm air hits you in the face. Wherever this chasm leads, there is volcanic activity present.","");
		set_flag(16,7,1);
		move_to_new_town(17,53,13);
break;

 beginstate 12;
	if (get_flag(16,1) == 0) {
		reset_dialog();
		add_dialog_str(0,"You enter the courtyard of the old fort. It is barren, only a few stunted trees are growing on it. The fort itself looks, like the walls, recently renovated.",0);
	if (get_flag(13,6) == 1)
		add_dialog_str(1,"Vitendo's rebels did a good job renovating the fort. They were determined to make the fort withstand an empire assault. However, the fort has now fallen into demon claws.",0);
		add_dialog_str(2,"Right now you hear the heavy footsteps of the infernal troopers. Some of them are patrolling the courtyard.",0);
		add_dialog_choice(0,"OK.");
		run_dialog(1);
		set_flag(16,1,1);
}
 break;

 beginstate 13;
	if (get_flag(16,3) == 0) {
		reset_dialog();
		add_dialog_str(0,"The exploding wall hanging punched a hole into, what looks like, barracks. Well over a dozen beds a placed in line. Right now it is inhabited by cackling imps, well mostly imps.",0);
	if (get_flag(13,6) == 1)
		add_dialog_str(1,"Before the imps attack you notice the beds don't look ancient. They have only gathered dust and filth, from about a month. Vitendo's men must have used them.",0);
	if (get_flag(13,6) == 0)
		add_dialog_str(2,"Despite the imps, you notice the beds are at most a few months old. Surely demons wouldn't use them.",0);
		add_dialog_choice(0,"OK.");
		run_dialog(1);
		set_flag(16,3,1);
}
 break;

 beginstate 14;
	if (get_flag(16,4) == 0) {
		reset_dialog();
		add_dialog_str(0,"Something terrible happened in this room. There are broken power sources, used for magic experiments, on the back of the room. A pentagram has been painted on the floor. From the ceiling over the pentagram, rubble has fallen to the ground.",0);
	if (get_flag(13,6) == 1)
		add_dialog_str(1,"This must be the room where Horendo summoned Kaejil Nyh'yltak from the infernal realm.",0);
	if (get_flag(13,6) == 0)
		add_dialog_choice(0,"OK.");
		run_dialog(1);
		set_flag(16,4,1);
}
 break;

 beginstate 15;
	if (get_flag(16,5) == 0) {
		message_dialog("This used to be the dinner hall. Now there is a huge hole, leading deep underneath the fortress. This isn't getting any easier.","");
		set_flag(16,5,1);
}
 break;

 beginstate 16;
	if (get_flag(16,6) == 0) {
		message_dialog("You find piece of parchment jammed between a book. It says. _It is all prepared. Horendo will attempt to summon the demon tonight. He is confident that controlling it will not be hard. With the demon as our puppet, we cannot lose.","Soon we will gave dozens of equally powerful demons and when the Empire dogs will assault, we will prevail. Faerengrove will finally be free of the scum! I must get prepared.
 - Vitendo_");
		set_flag(16,6,1);
}
 break;

 beginstate 17;
	message_dialog("This is the book which has the names of the prisoners. It is empty.","");
 break;